#!/bin/sh

name=om-gtun
debug=true

elfbin_files="./$name.elf /usr/bin/$name.elf"
config_files="./$name.config ~/.$name.config /etc/$name.config"
list_options="device threshold bufflen frontend"

# Load run options
for c in $config_files; do [ -f $c ] && . $c; done
run_options=$(for c in $list_options; do v=$(eval echo \$$c); ! [ -z $v ] && { echo " --$c $v"; }; done)' '$*

# Run executable
$(for e in $elfbin_files; do [ -x $e ] && { echo $(if ! [ "$debug" = "" ]; then echo "gdbserver 192.168.0.202:60000"; fi) $e $run_options; exit 0; }; done;
    echo 'echo ERROR: Executable was not found!';)

